package com.clas.liu.myapplication.presenter.impl;

import android.os.Handler;
import android.os.Message;

import com.clas.liu.myapplication.model.entity.notice.Notice;
import com.clas.liu.myapplication.model.event.AdministratorEvent;
import com.clas.liu.myapplication.model.impl.BaseModel;
import com.clas.liu.myapplication.model.impl.PublishNoticeModel;
import com.clas.liu.myapplication.presenter.i.IPublishNiticePresenter;
import com.clas.liu.myapplication.view.activity.impl.BaseActivity;
import com.clas.liu.myapplication.view.activity.impl.PublishNoticeActivity;

/**
 * Created by liu on 2019/5/26.
 */

public class PublishNoticePresenter extends BasePresenter<PublishNoticeActivity, PublishNoticeModel> implements IPublishNiticePresenter {
    public PublishNoticePresenter(PublishNoticeActivity view) {
        super(view);
    }

    @Override
    public void postNotice(Notice notice) {
        mModel.postNotice(notice);
    }

    @Override
    protected PublishNoticeModel getModel(Handler handler) {
        return new PublishNoticeModel(handler);
    }

    @Override
    protected void eventReceive(Message msg) {
        switch (msg.what) {
            case AdministratorEvent.POST_NOTICE_FAIL:
                mView.failBecauseNetReturn(msg.what);
                break;
            case AdministratorEvent.POST_NOTICE_OK:
                mView.postReturn();
                break;
        }
    }
}
